﻿<UserControl x:Class="ContestMeter.Teacher.UI.ConfigurationEditorView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <StackPanel>

            <Label>Имя файла со сведениями об участниках:</Label>
            <Label Content="{Binding Configuration.InfoPath}"/>

            <Label>Задания</Label>
        </StackPanel>

        <ListView Grid.Row="1" ItemsSource="{Binding Configuration.Tasks}">
            <ListView.Resources>
                <Style TargetType="TextBox">
                    <Setter Property="BorderThickness" Value="0"/>
                    <Setter Property="Background" Value="Transparent"/>
                </Style>
            </ListView.Resources>
            <ListView.View>
                <GridView>
                    <GridViewColumn  Header="Название задачи"  Width="200">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox MinWidth="100" Text="{Binding Name}" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>

                    <GridViewColumn Header="Краткое название" Width="200">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox MinWidth="100" Text="{Binding ExecutableName}"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Проверяющая программа (с расширением)" Width="200">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox MinWidth="100" Text="{Binding CheckerName}"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Папка с тестами" Width="200">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox MinWidth="100" Text="{Binding TestsFolder}"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Предел выполнения" Width="200">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox MinWidth="100" Text="{Binding TimeLimit}"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Цена одного теста" Width="200">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox MinWidth="100" Text="{Binding Weight}"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Width="90">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Button Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Grid},  Path=DataContext.DeleteCommand}" CommandParameter="{Binding .}">Удалить</Button>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>

        
        <Label Grid.Row="2">Компиляторы:</Label>
        <ListView Grid.Row="3" ItemsSource="{Binding Configuration.DevTools}">
            <ListView.View>
                
                <GridView>
                    
                    <GridViewColumn Header="Название" Width="200">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox MinWidth="100" Text="{Binding Name}"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                        
                    </GridViewColumn>
                    <GridViewColumn Header="Исполняемый файл" Width="200">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox MinWidth="100" Text="{Binding CompileCommand}"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Шаблон командной строки" Width="200">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox MinWidth="100" Text="{Binding CommandArgs}"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Width="90">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Button Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Grid},  Path=DataContext.DeleteToolCommand}" CommandParameter="{Binding .}">Удалить</Button>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    
                </GridView>
                
            </ListView.View>
        </ListView>

        <StackPanel Orientation="Horizontal" Grid.Row="4">

            <Button Command="{Binding AddCommand}" HorizontalAlignment="Right" Margin="10" Width="120" Height="25">Добавить задание</Button>
            <Button Command="{Binding AddToolCommand}" HorizontalAlignment="Right" Margin="10" Width="150" Height="25">Добавить компилятор</Button>
            <Button Command="{Binding SaveCommand}" HorizontalAlignment="Right" Margin="10" Width="120" Height="25">Сохранить</Button>
        </StackPanel>    
    
    </Grid>
</UserControl>
